# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=oslo-serialization
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=5.1.1
pkgrel=2
pkgdesc="Oslo Serialization library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://pypi.org/project/oslo.serialization/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-pbr"
         "${MINGW_PACKAGE_PREFIX}-python-msgpack"
         "${MINGW_PACKAGE_PREFIX}-python-oslo-utils"
         "${MINGW_PACKAGE_PREFIX}-python-pytz")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-oslotest")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-$pkgver.tar.gz"::"https://github.com/openstack/oslo.serialization/archive/${pkgver}.tar.gz")
sha512sums=('e4803ff22563b5790522cc09831078f071a16345017e2dc2231ba2d2a2dc466f44eed84fe3afb135b7724ce4ca6f4ceac4bcc1ae1c89fdcac6aafa414097caea')

prepare() {
  cd "${srcdir}/oslo.serialization-${pkgver}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
  # set version for pbr
  export PBR_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/oslo.serialization-${pkgver}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/oslo.serialization-${pkgver}"
  PYTHON=${MINGW_PREFIX}/bin/python ${MINGW_PREFIX}/bin/stestr run || warning "Tests failed"
}

package() {
  cd "${srcdir}/oslo.serialization-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
